ifeq ($(OS), WINDOWS)
	RM=del /F /Q
	RM_REC=del /F /S /Q
	LDFLAGS=#-lpthreadGC2 -lregex -lws2_32 #-fPIC
	SEP=\\
	MAKE=mingw32-make
	LIB=libnetwork.a
else
	RM=rm -f
	RM_REC=rm -f -r
	CXXFLAGS=#-fPIC
	LDFLAGS=#-fPIC
	SEP=/
	MAKE=make
	LIB=libnetwork.a
endif

CXX=g++
CXXFLAGS+= -Wall -Wextra -pedantic -ansi -O3   -Wformat=2 -Winit-self -Wwrite-strings
SRC=$(wildcard src/*.cpp)
OBJ=$(SRC:src/%.cpp=obj$(SEP)%.o)


all: lib$(SEP)$(LIB)
	

lib$(SEP)$(LIB): $(OBJ)
	ar -rv $@ $^ $(LDFLAGS)

obj$(SEP)%.o: src$(SEP)%.cpp src$(SEP)%.h
	$(CXX) -c $< -o $@ $(CXXFLAGS)

obj$(SEP)%.o: src$(SEP)%.cpp
	$(CXX) -c $< -o $@ $(CXXFLAGS)


.PHONY: clean mrproper doc


clean:
	$(RM) obj$(SEP)*.o

mrproper: clean
	$(RM) lib$(SEP)$(LIB)
	$(RM_REC) doc$(SEP)*

doc:
	doxygen confdoc

